package org.real.guetshop.controller.general;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.real.guetshop.pojo.dto.ValifyDTO;
import org.real.guetshop.result.Result;
import org.real.guetshop.utils.EmailUtil;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/general")
@Slf4j
public class GeneralController {

    @Resource
    private EmailUtil emailUtil;

    /**
     * 发送邮件
     *
     * @param email
     * @return
     */
    @PostMapping("/send")
    public Result sentEmail(@RequestParam String email) {
        log.info("开始发送邮件：{}",email);
        emailUtil.sendEmail(email);
        return Result.success();
    }

    /**
     * 验证码校验
     * @param valifyDTO
     * @return
     */
    @PostMapping("/valify")
    public Result valify(@RequestBody ValifyDTO valifyDTO){
        log.info("开始验证码校验：{}",valifyDTO);
        emailUtil.valify(valifyDTO);
        return Result.success();
    }
}
